package com.typhoon.dao

import com.typhoon.entity.User
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.jdbc.core.BeanPropertyRowMapper
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Repository

@Repository
class UserDao {

    @Autowired
    private lateinit var jdbcTemplate:JdbcTemplate
    fun getByPK(id:Long) : User? {
        var sql = "select * from User where id = ? limit 1"
        var  list = this.jdbcTemplate.query(sql,BeanPropertyRowMapper.newInstance(User::class.java),id)
        return list?.get(0)
    }

}